#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=100000;

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static int p[maxn+1], d[maxn+1], ans[maxn+1];
  int n, l, left=0, cnt=0;
  scanf("%d %d", &n, &l);
  for (int i=1; i<=n; i++) scanf("%d", p+i);
  for (int i=1; i<=n; i++) {
    scanf("%d", d+i);
    left += d[i];
  }

  cnt = 0;
  for (int i=1; i<=n; i++) {
    if (d[i]) {
      cnt++;
      ans[n-left+cnt] = l-p[i];
    }
  }
  cnt = 0;
  for (int i=n; i>0; i--) {
    if (!d[i]) {
      cnt++;
      ans[n-left-cnt+1] = p[i];
    }
  }

  for (int i=1; i<=n; i++) printf("%d ", ans[i]);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
